package edu.berkeley.drivingbuddy;

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.EditText;

public class newCourseDone extends Activity implements OnClickListener {
    
    Button mButtonNewCourseContinue;
    EditText mEditTextCourseName;
	ResultObj mResult;

	int resultId;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newcoursedone);

		resultId = getIntent().getExtras().getInt("id");
		mResult = DrivingBuddy.getDatastore().getResultById(resultId);
        
        mButtonNewCourseContinue = (Button) findViewById(R.id.button_newcoursedone_continue);
		((TextView) findViewById(R.id.textview_newcourse_score)).setText("Score: " +  mResult.getScore());
        mEditTextCourseName = (EditText) findViewById(R.id.edittext_newcoursedone_coursename);
		mEditTextCourseName.setText(mResult.getGroup().getName());
        
        mButtonNewCourseContinue.setOnClickListener(this);
    }
    
    public void onClick (View v) {
		mResult.getGroup().setName(mEditTextCourseName.getText().toString());
        startActivity(new Intent(this, Result.class).putExtra("id", resultId));
    }

}
